package com.woniuxy.carlife.carlifenewcomplaintsweb.controller;


import com.woniuxy.carlife.carlifecommonsweb.responsetemplate.Result;
import com.woniuxy.carlife.carlifecommonsweb.responsetemplate.StatusCode;
import com.woniuxy.carlife.carlifenewcomplaintsdomain.dto.MessageCategoryDto;
import com.woniuxy.carlife.carlifenewcomplaintsweb.service.MessageCategoryService;
import com.woniuxy.carlife.carlifenewcomplaintsweb.utils.StatusMessageEnum;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yp
 * @ClassName:MessageCategoryController
 * @Description:消息类别
 * @date 2021/4/7 2:32
 **/
@RestController
@Slf4j
@Api(tags = "消息类别管理接口")
@RequestMapping("/messageCategory")
public class MessageCategoryController {

    @Resource
    private MessageCategoryService messageCategoryService;

    /*
     * 功能描述〈查询出所有的消息类别〉
     * @author:yp
     * @param: null
     * @return:List<MessageCategoryDto>
     * @Date 2021/4/12 9:38
     * @throws
     */
    @GetMapping("/ordinary/findAll")
    @ApiOperation(value = "查询消息类别信息",notes = "<span style='color:red;'>查询消息类别信息的接口</span>")
    @ApiResponses({
            @ApiResponse(code = 20000,message = "查询成功"),
            @ApiResponse(code=20001,message = "查询失败")
    })
    public Result findAll(){
        log.info("开始业务:查询消息类别");
        List<MessageCategoryDto> list=messageCategoryService.findAll();
        log.info("结束业务:查询消息类别");
        if (list.size()!=0){
            return new Result(true, StatusCode.OK, StatusMessageEnum.FIND_SUCCESS.toString(),list);
        }
        return new Result(false,StatusCode.ERROR,StatusMessageEnum.FIND_FAIL.toString());
    }
}

